<script lang="tsx" setup>
/**
 * 侧边栏
 */
import {definePageTree, PageTree} from "@/frame/view/layout/page-tree/constructor.ts"
import {ref} from "vue"
import APIS from "@/apis"
import {SelectUrl} from "@/utils/base-url.ts"

/**
 * 定义emit
 */
const emit = defineEmits<{
  (e: "change", node: Node): void
}>()

/**
 * 组件实例
 */
const treeRef = ref<any>()
const config = definePageTree<any>({
  url: SelectUrl(APIS.DEPARTMENT_BASE),
  title: "部门列表",
  searchForm: {
    els: [
      {
        label: "部门名称",
        eType: "el-input",
        prop: "keyWord",
        props: {
          placeholder: "部门名称",
          clearable: true
        }
      }
    ]
  },
  bottom: {
    show: false
  },
  tree: {
    event: {
      nodeClick: (node: Node) => {
        emit("change", node)
      }
    },
    prop: {
      children: "item",
      label: "name"
    }
  }
})
</script>

<template>
  <PageTree ref="treeRef" :config="config"/>
</template>

<style lang="scss" scoped>

</style>